package com.gdth.bank.presenter;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import com.gdth.bank.bean.XtBbGxBean;
import com.gdth.bank.model.XtBbGxModel;
import com.gdth.bank.view.XtBbGxView;
import com.gdth.http.entity.HttpResult;
import com.google.gson.Gson;

public class XtBbGxPresenter {
     private XtBbGxView  mXtBbGxView;
     private XtBbGxModel mXtBbGxModel;
     public XtBbGxPresenter(XtBbGxView mXtBbGxView) {
         this.mXtBbGxView = mXtBbGxView;
         mXtBbGxModel = new XtBbGxModel();
     }
     public void getBbGx(String content){
    	 mXtBbGxModel.getBbGx(content)
 			.subscribeOn(Schedulers.io())
 			.unsubscribeOn(Schedulers.io())
 			.observeOn(AndroidSchedulers.mainThread())
 			.subscribe(new Subscriber<String>(){

 				@Override
 				public void onCompleted() {
 					// TODO Auto-generated method stub
 					
 				}
 	
 				@Override
 				public void onError(Throwable arg0) {
 					// TODO Auto-generated method stub
 					mXtBbGxView.showMessage("获取最新app版本信息失败:" + arg0.getMessage());
 				}
 	
 				@Override
 				public void onNext(String arg0) {
 					// TODO Auto-generated method stub
 					
 					XtBbGxBean  mXtBbGxBean= new XtBbGxBean();
 					
 	            	Gson mGson = new Gson();
 	            	mXtBbGxBean = mGson.fromJson(arg0, mXtBbGxBean.getClass());
 	            	
 	            	mXtBbGxView.getXtBbGxData(mXtBbGxBean);
 				}
 		});
     }
     
}
